package common.data.location
{
	import common.model.WqEleFence;
	import common.model.WqMapRegion;
	import common.model.WqRule;
	
	import mx.collections.ArrayCollection;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;

	/**
	 * 电子围栏服务类
	 */
	public class EnclosureService extends RemoteObject
	{
		/**
		 * 获取电子围栏
		 */
		public var findWqMapRegionByWqEleFenceHandle:Function;
		public var findWqEleFenceHandle:Function;
		public var updateWqEleFenceRegionHandle:Function;
		public var saveOrUpdateWqEleFenceHandle:Function;
		public var deleteWqEleFenceHandle:Function;
		public var findWqRuleByWqEleFenceHandle:Function;
		public var saveOrUpdateWqRuleHandle:Function;
		public var deleteWqRuleHandle:Function;
		public var findWqStaffInfoByWqRuleHandle:Function;
		public var findMapRegoinByIdsHandle:Function;
		
		public function EnclosureService()
		{
			super("enclosureService");
			this.showBusyCursor = true;
			this.getOperation("findWqMapRegionByWqEleFence").addEventListener(ResultEvent.RESULT,findWqMapRegionByWqEleFenceResult,false,0,true);
			this.getOperation("findWqEleFence").addEventListener(ResultEvent.RESULT,findWqEleFenceResult,false,0,true);
			this.getOperation("saveOrUpdateWqEleFence").addEventListener(ResultEvent.RESULT,saveOrUpdateWqEleFenceResult,false,0,true);
			this.getOperation("deleteWqEleFence").addEventListener(ResultEvent.RESULT,deleteWqEleFenceResult,false,0,true);
			this.getOperation("findWqRuleByWqEleFence").addEventListener(ResultEvent.RESULT,findWqRuleByWqEleFenceResult,false,0,true);
			this.getOperation("saveOrUpdateWqRule").addEventListener(ResultEvent.RESULT,saveOrUpdateWqRuleResult,false,0,true);
			this.getOperation("deleteWqRule").addEventListener(ResultEvent.RESULT,deleteWqRuleResult,false,0,true);
			this.getOperation("findWqStaffInfoByWqRule").addEventListener(ResultEvent.RESULT,findWqStaffInfoByWqRuleResult,false,0,true);
			this.getOperation("updateWqEleFenceRegion").addEventListener(ResultEvent.RESULT,updateWqEleFenceRegionResult,false,0,true);
			this.getOperation("findMapRegoinByIds").addEventListener(ResultEvent.RESULT,findMapRegoinByIdsResult,false,0,true);
		}
//电子围栏		
		
		//查询电子围栏区域
		public function findWqMapRegionByWqEleFence(wqEleFence:WqEleFence):void{
			this.getOperation("findWqMapRegionByWqEleFence").send(wqEleFence);
		}
		
		//回调获取电子围栏区域
		public function findWqMapRegionByWqEleFenceResult(e:ResultEvent):void{
			try{
				if(findWqMapRegionByWqEleFenceHandle){
					findWqMapRegionByWqEleFenceHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//查询电子围栏
		public function findWqEleFence():void{
			this.getOperation("findWqEleFence").send();
		}
		
		//回调获取电子围栏
		private function findWqEleFenceResult(e:ResultEvent):void{
			try{
				if(findWqEleFenceHandle){
					findWqEleFenceHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		public function updateWqEleFenceRegion(wqEleFence:WqEleFence,region:WqMapRegion):void{
			this.getOperation("updateWqEleFenceRegion").send(wqEleFence,region);
		}
		
		private function updateWqEleFenceRegionResult(e:ResultEvent):void{
			try{
				if(updateWqEleFenceRegionHandle){
					updateWqEleFenceRegionHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		//保存或修改电子围栏
		public function saveOrUpdateWqEleFence(wqEleFence:WqEleFence):void{
			this.getOperation("saveOrUpdateWqEleFence").send(wqEleFence);
		}
		
		//回调保存或修改电子围栏
		private function saveOrUpdateWqEleFenceResult(e:ResultEvent):void{
			try{
				if(saveOrUpdateWqEleFenceHandle){
					saveOrUpdateWqEleFenceHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//删除电子围栏
		public function deleteWqEleFence(wqEleFence:WqEleFence):void{
			this.getOperation("deleteWqEleFence").send(wqEleFence);
		}
		
		//回调删除电子围栏
		private function deleteWqEleFenceResult(e:ResultEvent):void{
			try{
				if(deleteWqEleFenceHandle){
					deleteWqEleFenceHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
//围栏规则
		
		//查询围栏规则
		public function findWqRuleByWqEleFence(wqEleFence:WqEleFence):void{
			this.getOperation("findWqRuleByWqEleFence").send(wqEleFence);
		}
		
		//回调获取围栏规则
		private function findWqRuleByWqEleFenceResult(e:ResultEvent):void{
			try{
				if(findWqRuleByWqEleFenceHandle){
					findWqRuleByWqEleFenceHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		
		//保存或修改围栏规则
		public function saveOrUpdateWqRule(wqRule:WqRule,ac:ArrayCollection):void{
			this.getOperation("saveOrUpdateWqRule").send(wqRule,ac);
		}
		
		//回调保存或修改围栏规则
		private function saveOrUpdateWqRuleResult(e:ResultEvent):void{
			try{
				if(saveOrUpdateWqRuleHandle){
					saveOrUpdateWqRuleHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//删除围栏规则
		public function deleteWqRule(wqRule:WqRule):void{
			this.getOperation("deleteWqRule").send(wqRule);
		}
		
		//回调围栏规则
		private function deleteWqRuleResult(e:ResultEvent):void{
			try{
				if(deleteWqRuleHandle){
					deleteWqRuleHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//查询根据围栏规则获取分配的员工集合
		public function findWqStaffInfoByWqRule(wqRule:WqRule):void{
			this.getOperation("findWqStaffInfoByWqRule").send(wqRule);
		}
		
		//回调根据围栏规则获取分配的员工集合
		private function findWqStaffInfoByWqRuleResult(e:ResultEvent):void{
			try{
				if(findWqStaffInfoByWqRuleHandle){
					findWqStaffInfoByWqRuleHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		public function findMapRegoinByIds(regionIds:Array):void{
			this.getOperation("findMapRegoinByIds").send(regionIds);
		}
		private function findMapRegoinByIdsResult(e:ResultEvent):void{
			try{
				if(findMapRegoinByIdsHandle){
					findMapRegoinByIdsHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		
	}
}	